<?php 
	include("php/header.php");
	include("php/db.php");
	$sqlUebung = "SELECT * FROM t_uebung ORDER BY ueb_datum";
	$resUebung = $db->query($sqlUebung);
	echo "<form name=\"addUebung\" method=\"POST\" action=\"php/addUebung.php\">";
	echo "<h1>Neue Übung anlegen </h1>";
	echo "<table id=\"uebung\" border=\"1\">";
	echo "<tr><th>NR</th><th>Datum</th><th>Beginn</th></tr>";
	echo "<tr><td>";
	echo "<input type=\"text\" name=\"uebNr\"/>";
	echo "</td><td>";
	$date = getdate();
	echo "<input type=\"text\" name=\"uebDatum\" value=\"".$date['year']."-".$date['mon']."-".$date['mday']."\"/>";
	echo "</td><td>";
	echo "<input type=\"text\" name=\"uebBeginn\" value=\"".$date['hours'].":".$date['minutes']."\"/>";
	echo "</td><td>";
	//	<a href="javascript:addUebung()">Anlegen</a>
	?>
    <input type="submit" value="Anlegen"  />
	</form>
    <?php
	echo "</td></tr>";
	echo "</table>";
	echo "<h1>Übungen</h1>";
	echo "<div id=\"test\"></div>";
	echo "<table id=\"uebung\" border=\"1\">";
	echo "<tr><th>NR</th><th>Datum</th><th></th><th></th></tr>";
	while ($rowUebung = $resUebung->fetch_assoc()) {
		echo "<tr><td>";
		echo $rowUebung['ueb_nr'];
		echo "</td><td>";
		echo $rowUebung['ueb_datum'];
		echo "</td><td>";
		echo "<a href=\"lauf.php?ueb_id=".$rowUebung['ueb_id']."\" >Auswählen</a>";
		echo "</td><td><input type=\"button\" value=\"löschen\" onclick=\"deleteUebung(".$rowUebung['ueb_id'].")\" />";
		echo "</td></tr>";
	}
	echo "</table>";
	echo "</form>";
?>
<?php include ("php/footer.php"); ?>